// 2025/11/9
// 两数之和

class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        int n = nums.size();
        unordered_map<int, int> val_pos;
        for(int i = 0; i < n; i++)
        {
            auto it = val_pos.find(target - nums[i]);
            if(it != val_pos.end())
            {
                return {i, it->second};
            }
            val_pos[nums[i]] = i;
        }
        return vector<int>();
    }
};